﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Globalization;
using System.Data;
using System.Xml;
using System.Text;
using LibHuman;


namespace Human
{
	/// <summary>
	/// Summary description for frmSucKhoeSua.
	/// </summary>
	public class frmSucKhoe : System.Windows.Forms.Form
	{
        private string TSo = "", sql = "", ten_nd = "", m_user = "";
        private AccessData mDB = new AccessData();
        Language lan = new Language();
		public DataSet ds =new DataSet();
		private DataSet ds1=new DataSet();
        private bool admin = false;
        int flag = 0;
		private System.Windows.Forms.Panel panCongTac;
		private System.Windows.Forms.Label lblTenPhongCT;
		private System.Windows.Forms.Label lblHoTenNVCT;
		private System.Windows.Forms.Label label29;
		private System.Windows.Forms.Label lblMasoNVCT;
		private System.Windows.Forms.Label label28;
        private System.Windows.Forms.GroupBox groupSK;
        private System.Windows.Forms.TextBox txtGC_SK;
		private System.Windows.Forms.TextBox txtTHSK_SK;
		private System.Windows.Forms.TextBox txtL_SK;
		private System.Windows.Forms.Label label181;
		private System.Windows.Forms.Label label182;
		private System.Windows.Forms.Label label183;
		private System.Windows.Forms.Label label184;
        private System.Windows.Forms.Label label185;
		private System.Windows.Forms.Label label120;
		private System.Windows.Forms.TextBox txtNhanDang;
		private System.Windows.Forms.TextBox txtTSo;
        private System.Windows.Forms.Label label27;
		private System.Windows.Forms.ContextMenu dgrSusKhoecontextMenu;
		private System.Windows.Forms.MenuItem menuItem1;
        private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.Panel panel1;
        private Panel panel2;
        private Label label1;
        private DataGridView dataGridView1;
        private TextBox txtID;
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private DataGridViewTextBoxColumn Column3;
        private DataGridViewTextBoxColumn Column4;
        private DataGridViewTextBoxColumn Column5;
        private DataGridViewTextBoxColumn Column6;
        private DataGridViewTextBoxColumn Column7;
        private MaskedTextBox txtDN_SK;
        private MaskedTextBox txtTN_SK;
        private ComboBox cmbloai;
        private CheckBox checkthuongtat;
        private Label label3;
        private Label label2;
        private Button btn_them;
        private Button btn_edit;
        private Button btn_luu;
        private Button btn_boqua;
        private Button btn_huy;
        private Button btn_xoa;
        private Button btn_thoat;
		private System.ComponentModel.IContainer components;

		public frmSucKhoe(string manv,string hoten,string madv,bool m_admin,string tennd)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
            m_user = mDB.user;
			lblMasoNVCT.Text=manv;
			lblHoTenNVCT.Text=hoten;
			lblTenPhongCT.Text=madv;			
			tongso();
            admin = m_admin;
            ten_nd = tennd;
			if (Screen.PrimaryScreen.WorkingArea.Width>=1000)//
			{
				
				this.WindowState=FormWindowState.Normal;
				this.MaximizeBox=false;
			}
			else
			{
				
				this.WindowState=FormWindowState.Maximized;
			}
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmSucKhoe));
            this.panCongTac = new System.Windows.Forms.Panel();
            this.label1 = new System.Windows.Forms.Label();
            this.lblTenPhongCT = new System.Windows.Forms.Label();
            this.lblHoTenNVCT = new System.Windows.Forms.Label();
            this.label29 = new System.Windows.Forms.Label();
            this.lblMasoNVCT = new System.Windows.Forms.Label();
            this.label28 = new System.Windows.Forms.Label();
            this.groupSK = new System.Windows.Forms.GroupBox();
            this.cmbloai = new System.Windows.Forms.ComboBox();
            this.checkthuongtat = new System.Windows.Forms.CheckBox();
            this.txtDN_SK = new System.Windows.Forms.MaskedTextBox();
            this.txtTN_SK = new System.Windows.Forms.MaskedTextBox();
            this.txtID = new System.Windows.Forms.TextBox();
            this.txtGC_SK = new System.Windows.Forms.TextBox();
            this.txtTHSK_SK = new System.Windows.Forms.TextBox();
            this.txtL_SK = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label181 = new System.Windows.Forms.Label();
            this.label182 = new System.Windows.Forms.Label();
            this.label183 = new System.Windows.Forms.Label();
            this.label184 = new System.Windows.Forms.Label();
            this.label185 = new System.Windows.Forms.Label();
            this.dgrSusKhoecontextMenu = new System.Windows.Forms.ContextMenu();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.label120 = new System.Windows.Forms.Label();
            this.txtNhanDang = new System.Windows.Forms.TextBox();
            this.txtTSo = new System.Windows.Forms.TextBox();
            this.label27 = new System.Windows.Forms.Label();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.btn_thoat = new System.Windows.Forms.Button();
            this.btn_xoa = new System.Windows.Forms.Button();
            this.btn_huy = new System.Windows.Forms.Button();
            this.btn_boqua = new System.Windows.Forms.Button();
            this.btn_luu = new System.Windows.Forms.Button();
            this.btn_edit = new System.Windows.Forms.Button();
            this.btn_them = new System.Windows.Forms.Button();
            this.panel1 = new System.Windows.Forms.Panel();
            this.panel2 = new System.Windows.Forms.Panel();
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.panCongTac.SuspendLayout();
            this.groupSK.SuspendLayout();
            this.panel1.SuspendLayout();
            this.panel2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // panCongTac
            // 
            this.panCongTac.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.panCongTac.Controls.Add(this.label1);
            this.panCongTac.Controls.Add(this.lblTenPhongCT);
            this.panCongTac.Controls.Add(this.lblHoTenNVCT);
            this.panCongTac.Controls.Add(this.label29);
            this.panCongTac.Controls.Add(this.lblMasoNVCT);
            this.panCongTac.Controls.Add(this.label28);
            this.panCongTac.Dock = System.Windows.Forms.DockStyle.Top;
            this.panCongTac.Location = new System.Drawing.Point(0, 0);
            this.panCongTac.Name = "panCongTac";
            this.panCongTac.Size = new System.Drawing.Size(790, 40);
            this.panCongTac.TabIndex = 5;
            // 
            // label1
            // 
            this.label1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label1.Font = new System.Drawing.Font("Tahoma", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.White;
            this.label1.Location = new System.Drawing.Point(3, 0);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(131, 40);
            this.label1.TabIndex = 5;
            this.label1.Text = "SỨC KHỎE";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // lblTenPhongCT
            // 
            this.lblTenPhongCT.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.lblTenPhongCT.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblTenPhongCT.ForeColor = System.Drawing.Color.White;
            this.lblTenPhongCT.Location = new System.Drawing.Point(610, 0);
            this.lblTenPhongCT.Name = "lblTenPhongCT";
            this.lblTenPhongCT.Size = new System.Drawing.Size(180, 40);
            this.lblTenPhongCT.TabIndex = 4;
            this.lblTenPhongCT.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // lblHoTenNVCT
            // 
            this.lblHoTenNVCT.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.lblHoTenNVCT.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblHoTenNVCT.ForeColor = System.Drawing.Color.White;
            this.lblHoTenNVCT.Location = new System.Drawing.Point(374, 0);
            this.lblHoTenNVCT.Name = "lblHoTenNVCT";
            this.lblHoTenNVCT.Size = new System.Drawing.Size(240, 40);
            this.lblHoTenNVCT.TabIndex = 3;
            this.lblHoTenNVCT.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label29
            // 
            this.label29.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label29.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label29.ForeColor = System.Drawing.Color.White;
            this.label29.Location = new System.Drawing.Point(310, 0);
            this.label29.Name = "label29";
            this.label29.Size = new System.Drawing.Size(56, 40);
            this.label29.TabIndex = 2;
            this.label29.Text = "Họ tên ";
            this.label29.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // lblMasoNVCT
            // 
            this.lblMasoNVCT.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.lblMasoNVCT.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblMasoNVCT.ForeColor = System.Drawing.Color.White;
            this.lblMasoNVCT.Location = new System.Drawing.Point(221, 0);
            this.lblMasoNVCT.Name = "lblMasoNVCT";
            this.lblMasoNVCT.Size = new System.Drawing.Size(80, 40);
            this.lblMasoNVCT.TabIndex = 1;
            this.lblMasoNVCT.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label28
            // 
            this.label28.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label28.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label28.ForeColor = System.Drawing.Color.White;
            this.label28.Location = new System.Drawing.Point(157, 0);
            this.label28.Name = "label28";
            this.label28.Size = new System.Drawing.Size(56, 40);
            this.label28.TabIndex = 0;
            this.label28.Text = "Mã số ";
            this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // groupSK
            // 
            this.groupSK.Controls.Add(this.cmbloai);
            this.groupSK.Controls.Add(this.checkthuongtat);
            this.groupSK.Controls.Add(this.txtDN_SK);
            this.groupSK.Controls.Add(this.txtTN_SK);
            this.groupSK.Controls.Add(this.txtID);
            this.groupSK.Controls.Add(this.txtGC_SK);
            this.groupSK.Controls.Add(this.txtTHSK_SK);
            this.groupSK.Controls.Add(this.txtL_SK);
            this.groupSK.Controls.Add(this.label3);
            this.groupSK.Controls.Add(this.label2);
            this.groupSK.Controls.Add(this.label181);
            this.groupSK.Controls.Add(this.label182);
            this.groupSK.Controls.Add(this.label183);
            this.groupSK.Controls.Add(this.label184);
            this.groupSK.Controls.Add(this.label185);
            this.groupSK.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.groupSK.ForeColor = System.Drawing.Color.Blue;
            this.groupSK.Location = new System.Drawing.Point(3, 451);
            this.groupSK.Name = "groupSK";
            this.groupSK.Size = new System.Drawing.Size(784, 81);
            this.groupSK.TabIndex = 2;
            this.groupSK.TabStop = false;
            // 
            // cmbloai
            // 
            this.cmbloai.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbloai.Enabled = false;
            this.cmbloai.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmbloai.FormattingEnabled = true;
            this.cmbloai.Items.AddRange(new object[] {
            "Hạng 1",
            "Hạng 2",
            "Hạng 3",
            "Hạng 4"});
            this.cmbloai.Location = new System.Drawing.Point(495, 36);
            this.cmbloai.Name = "cmbloai";
            this.cmbloai.Size = new System.Drawing.Size(71, 23);
            this.cmbloai.TabIndex = 7;
            this.cmbloai.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbloai_KeyDown);
            // 
            // checkthuongtat
            // 
            this.checkthuongtat.AutoSize = true;
            this.checkthuongtat.Location = new System.Drawing.Point(419, 45);
            this.checkthuongtat.Name = "checkthuongtat";
            this.checkthuongtat.Size = new System.Drawing.Size(15, 14);
            this.checkthuongtat.TabIndex = 6;
            this.checkthuongtat.UseVisualStyleBackColor = true;
            this.checkthuongtat.CheckedChanged += new System.EventHandler(this.checkthuongtat_CheckedChanged);
            this.checkthuongtat.KeyDown += new System.Windows.Forms.KeyEventHandler(this.checkthuongtat_KeyDown);
            // 
            // txtDN_SK
            // 
            this.txtDN_SK.BackColor = System.Drawing.Color.White;
            this.txtDN_SK.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtDN_SK.ForeColor = System.Drawing.Color.Navy;
            this.txtDN_SK.Location = new System.Drawing.Point(319, 39);
            this.txtDN_SK.Mask = "00/00/0000";
            this.txtDN_SK.Name = "txtDN_SK";
            this.txtDN_SK.Size = new System.Drawing.Size(91, 21);
            this.txtDN_SK.TabIndex = 5;
            this.txtDN_SK.ValidatingType = typeof(System.DateTime);
            this.txtDN_SK.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDN_SK_KeyDown);
            this.txtDN_SK.Validated += new System.EventHandler(this.txtDN_SK_Validated);
            // 
            // txtTN_SK
            // 
            this.txtTN_SK.BackColor = System.Drawing.Color.White;
            this.txtTN_SK.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTN_SK.ForeColor = System.Drawing.Color.Navy;
            this.txtTN_SK.Location = new System.Drawing.Point(226, 39);
            this.txtTN_SK.Mask = "00/00/0000";
            this.txtTN_SK.Name = "txtTN_SK";
            this.txtTN_SK.Size = new System.Drawing.Size(91, 21);
            this.txtTN_SK.TabIndex = 4;
            this.txtTN_SK.ValidatingType = typeof(System.DateTime);
            this.txtTN_SK.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtTN_SK_KeyDown);
            this.txtTN_SK.Validated += new System.EventHandler(this.txtTN_SK_Validated);
            // 
            // txtID
            // 
            this.txtID.Location = new System.Drawing.Point(712, 15);
            this.txtID.Name = "txtID";
            this.txtID.Size = new System.Drawing.Size(46, 21);
            this.txtID.TabIndex = 58;
            // 
            // txtGC_SK
            // 
            this.txtGC_SK.BackColor = System.Drawing.Color.White;
            this.txtGC_SK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtGC_SK.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtGC_SK.Location = new System.Drawing.Point(574, 39);
            this.txtGC_SK.MaxLength = 50;
            this.txtGC_SK.Name = "txtGC_SK";
            this.txtGC_SK.Size = new System.Drawing.Size(201, 20);
            this.txtGC_SK.TabIndex = 8;
            this.txtGC_SK.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtGC_SK_KeyDown);
            this.txtGC_SK.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtGC_SK_KeyPress);
            // 
            // txtTHSK_SK
            // 
            this.txtTHSK_SK.BackColor = System.Drawing.Color.White;
            this.txtTHSK_SK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTHSK_SK.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtTHSK_SK.Location = new System.Drawing.Point(11, 39);
            this.txtTHSK_SK.MaxLength = 30;
            this.txtTHSK_SK.Name = "txtTHSK_SK";
            this.txtTHSK_SK.Size = new System.Drawing.Size(153, 20);
            this.txtTHSK_SK.TabIndex = 2;
            this.txtTHSK_SK.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtTHSK_SK_KeyDown);
            // 
            // txtL_SK
            // 
            this.txtL_SK.BackColor = System.Drawing.Color.White;
            this.txtL_SK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtL_SK.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtL_SK.Location = new System.Drawing.Point(168, 39);
            this.txtL_SK.MaxLength = 4;
            this.txtL_SK.Name = "txtL_SK";
            this.txtL_SK.Size = new System.Drawing.Size(56, 20);
            this.txtL_SK.TabIndex = 3;
            this.txtL_SK.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtL_SK_KeyDown);
            this.txtL_SK.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtL_SK_KeyPress);
            // 
            // label3
            // 
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.DarkBlue;
            this.label3.Location = new System.Drawing.Point(492, 19);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(27, 13);
            this.label3.TabIndex = 57;
            this.label3.Text = "Loại";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.DarkBlue;
            this.label2.Location = new System.Drawing.Point(416, 19);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(59, 13);
            this.label2.TabIndex = 57;
            this.label2.Text = "Thương tật";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label181
            // 
            this.label181.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label181.ForeColor = System.Drawing.Color.DarkBlue;
            this.label181.Location = new System.Drawing.Point(577, 21);
            this.label181.Name = "label181";
            this.label181.Size = new System.Drawing.Size(47, 13);
            this.label181.TabIndex = 57;
            this.label181.Text = "Ghi chú ";
            this.label181.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label182
            // 
            this.label182.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label182.ForeColor = System.Drawing.Color.DarkBlue;
            this.label182.Location = new System.Drawing.Point(319, 20);
            this.label182.Name = "label182";
            this.label182.Size = new System.Drawing.Size(56, 13);
            this.label182.TabIndex = 55;
            this.label182.Text = "Đến ngày ";
            this.label182.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label183
            // 
            this.label183.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label183.ForeColor = System.Drawing.Color.DarkBlue;
            this.label183.Location = new System.Drawing.Point(226, 20);
            this.label183.Name = "label183";
            this.label183.Size = new System.Drawing.Size(49, 13);
            this.label183.TabIndex = 10;
            this.label183.Text = "Từ ngày ";
            this.label183.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label184
            // 
            this.label184.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label184.ForeColor = System.Drawing.Color.DarkBlue;
            this.label184.Location = new System.Drawing.Point(176, 19);
            this.label184.Name = "label184";
            this.label184.Size = new System.Drawing.Size(30, 13);
            this.label184.TabIndex = 9;
            this.label184.Text = "Loại ";
            this.label184.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label185
            // 
            this.label185.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label185.ForeColor = System.Drawing.Color.DarkBlue;
            this.label185.Location = new System.Drawing.Point(15, 20);
            this.label185.Name = "label185";
            this.label185.Size = new System.Drawing.Size(98, 13);
            this.label185.TabIndex = 8;
            this.label185.Text = "Tình hình sức khoẻ";
            this.label185.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // dgrSusKhoecontextMenu
            // 
            this.dgrSusKhoecontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem1,
            this.menuItem2});
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 0;
            this.menuItem1.Text = "Thêm";
            this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
            // 
            // menuItem2
            // 
            this.menuItem2.Index = 1;
            this.menuItem2.Text = "Hủy";
            this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
            // 
            // label120
            // 
            this.label120.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label120.ForeColor = System.Drawing.Color.DarkBlue;
            this.label120.Location = new System.Drawing.Point(5, 6);
            this.label120.Name = "label120";
            this.label120.Size = new System.Drawing.Size(72, 24);
            this.label120.TabIndex = 111;
            this.label120.Text = "Nhân dạng ";
            this.label120.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtNhanDang
            // 
            this.txtNhanDang.BackColor = System.Drawing.Color.White;
            this.txtNhanDang.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtNhanDang.Location = new System.Drawing.Point(78, 9);
            this.txtNhanDang.MaxLength = 70;
            this.txtNhanDang.Name = "txtNhanDang";
            this.txtNhanDang.Size = new System.Drawing.Size(683, 20);
            this.txtNhanDang.TabIndex = 1;
            this.txtNhanDang.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNhanDang_KeyDown);
            this.txtNhanDang.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtNhanDang_KeyPress);
            // 
            // txtTSo
            // 
            this.txtTSo.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTSo.ForeColor = System.Drawing.Color.Red;
            this.txtTSo.Location = new System.Drawing.Point(70, 9);
            this.txtTSo.Name = "txtTSo";
            this.txtTSo.Size = new System.Drawing.Size(64, 22);
            this.txtTSo.TabIndex = 114;
            this.txtTSo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtTSo.Visible = false;
            this.txtTSo.WordWrap = false;
            // 
            // label27
            // 
            this.label27.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label27.ForeColor = System.Drawing.Color.Blue;
            this.label27.Location = new System.Drawing.Point(6, 13);
            this.label27.Name = "label27";
            this.label27.Size = new System.Drawing.Size(63, 13);
            this.label27.TabIndex = 116;
            this.label27.Text = "Tổng  Số ";
            this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label27.Visible = false;
            // 
            // btn_thoat
            // 
            this.btn_thoat.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_thoat.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_thoat.Image = global::Human.Properties.Resources.close_r;
            this.btn_thoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_thoat.Location = new System.Drawing.Point(592, 6);
            this.btn_thoat.Name = "btn_thoat";
            this.btn_thoat.Size = new System.Drawing.Size(75, 28);
            this.btn_thoat.TabIndex = 124;
            this.btn_thoat.Text = "&Kết thúc";
            this.btn_thoat.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.btn_thoat, "Alt+K");
            this.btn_thoat.UseVisualStyleBackColor = true;
            this.btn_thoat.Click += new System.EventHandler(this.btn_thoat_Click);
            // 
            // btn_xoa
            // 
            this.btn_xoa.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_xoa.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_xoa.Image = global::Human.Properties.Resources.delete_enabled;
            this.btn_xoa.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_xoa.Location = new System.Drawing.Point(521, 6);
            this.btn_xoa.Name = "btn_xoa";
            this.btn_xoa.Size = new System.Drawing.Size(65, 28);
            this.btn_xoa.TabIndex = 123;
            this.btn_xoa.Text = "   &Xóa";
            this.toolTip1.SetToolTip(this.btn_xoa, "Alt+X");
            this.btn_xoa.UseVisualStyleBackColor = true;
            this.btn_xoa.Click += new System.EventHandler(this.btn_xoa_Click);
            // 
            // btn_huy
            // 
            this.btn_huy.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_huy.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_huy.Image = global::Human.Properties.Resources.Cancel;
            this.btn_huy.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_huy.Location = new System.Drawing.Point(450, 6);
            this.btn_huy.Name = "btn_huy";
            this.btn_huy.Size = new System.Drawing.Size(65, 28);
            this.btn_huy.TabIndex = 122;
            this.btn_huy.Text = "   &Hủy";
            this.toolTip1.SetToolTip(this.btn_huy, "Alt+H");
            this.btn_huy.UseVisualStyleBackColor = true;
            this.btn_huy.Click += new System.EventHandler(this.btn_huy_Click);
            // 
            // btn_boqua
            // 
            this.btn_boqua.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_boqua.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_boqua.Image = global::Human.Properties.Resources.undo_ok;
            this.btn_boqua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_boqua.Location = new System.Drawing.Point(374, 6);
            this.btn_boqua.Name = "btn_boqua";
            this.btn_boqua.Size = new System.Drawing.Size(70, 28);
            this.btn_boqua.TabIndex = 121;
            this.btn_boqua.Text = "&Bỏ qua";
            this.btn_boqua.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.btn_boqua, "Alt+B");
            this.btn_boqua.UseVisualStyleBackColor = true;
            this.btn_boqua.Click += new System.EventHandler(this.btn_boqua_Click);
            // 
            // btn_luu
            // 
            this.btn_luu.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_luu.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_luu.Image = global::Human.Properties.Resources.save;
            this.btn_luu.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_luu.Location = new System.Drawing.Point(303, 6);
            this.btn_luu.Name = "btn_luu";
            this.btn_luu.Size = new System.Drawing.Size(65, 28);
            this.btn_luu.TabIndex = 120;
            this.btn_luu.Text = "   &Lưu";
            this.toolTip1.SetToolTip(this.btn_luu, "Alt+L");
            this.btn_luu.UseVisualStyleBackColor = true;
            this.btn_luu.Click += new System.EventHandler(this.btn_luu_Click);
            this.btn_luu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btn_luu_KeyDown);
            // 
            // btn_edit
            // 
            this.btn_edit.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_edit.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_edit.Image = global::Human.Properties.Resources.quick_edit;
            this.btn_edit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_edit.Location = new System.Drawing.Point(232, 6);
            this.btn_edit.Name = "btn_edit";
            this.btn_edit.Size = new System.Drawing.Size(65, 28);
            this.btn_edit.TabIndex = 119;
            this.btn_edit.Text = "  &Sửa";
            this.toolTip1.SetToolTip(this.btn_edit, "Alt+S");
            this.btn_edit.UseVisualStyleBackColor = true;
            this.btn_edit.Click += new System.EventHandler(this.btn_edit_Click);
            // 
            // btn_them
            // 
            this.btn_them.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_them.ForeColor = System.Drawing.Color.DarkBlue;
            this.btn_them.Image = global::Human.Properties.Resources.add;
            this.btn_them.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_them.Location = new System.Drawing.Point(160, 6);
            this.btn_them.Name = "btn_them";
            this.btn_them.Size = new System.Drawing.Size(65, 28);
            this.btn_them.TabIndex = 118;
            this.btn_them.Text = "&Thêm";
            this.btn_them.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.btn_them, "Alt+T");
            this.btn_them.UseVisualStyleBackColor = true;
            this.btn_them.Click += new System.EventHandler(this.btn_them_Click);
            this.btn_them.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btn_them_KeyDown);
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.btn_thoat);
            this.panel1.Controls.Add(this.btn_xoa);
            this.panel1.Controls.Add(this.btn_huy);
            this.panel1.Controls.Add(this.btn_boqua);
            this.panel1.Controls.Add(this.btn_luu);
            this.panel1.Controls.Add(this.btn_edit);
            this.panel1.Controls.Add(this.btn_them);
            this.panel1.Controls.Add(this.txtTSo);
            this.panel1.Controls.Add(this.label27);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel1.Location = new System.Drawing.Point(0, 532);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(790, 39);
            this.panel1.TabIndex = 119;
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.txtNhanDang);
            this.panel2.Controls.Add(this.label120);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel2.Location = new System.Drawing.Point(0, 40);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(790, 34);
            this.panel2.TabIndex = 120;
            // 
            // dataGridView1
            // 
            this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
            dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
            this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
            this.dataGridView1.ColumnHeadersHeight = 25;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4,
            this.Column5,
            this.Column6,
            this.Column7});
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Top;
            this.dataGridView1.Location = new System.Drawing.Point(0, 74);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.RowHeadersWidth = 25;
            this.dataGridView1.Size = new System.Drawing.Size(790, 371);
            this.dataGridView1.TabIndex = 121;
            this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
            this.dataGridView1.CurrentCellChanged += new System.EventHandler(this.dataGridView1_CurrentCellChanged);
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "benhly";
            this.Column1.HeaderText = "Tình hình sức khoẻ";
            this.Column1.Name = "Column1";
            this.Column1.Width = 220;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "loai";
            this.Column2.HeaderText = "Loại";
            this.Column2.Name = "Column2";
            this.Column2.Width = 80;
            // 
            // Column3
            // 
            this.Column3.DataPropertyName = "tg_dau";
            this.Column3.HeaderText = "Từ ngày";
            this.Column3.Name = "Column3";
            // 
            // Column4
            // 
            this.Column4.DataPropertyName = "tg_cuoi";
            this.Column4.HeaderText = "Đến ngày";
            this.Column4.Name = "Column4";
            // 
            // Column5
            // 
            this.Column5.DataPropertyName = "ghichu";
            this.Column5.HeaderText = "Ghi chú";
            this.Column5.Name = "Column5";
            this.Column5.Width = 280;
            // 
            // Column6
            // 
            this.Column6.DataPropertyName = "id";
            this.Column6.HeaderText = "id";
            this.Column6.Name = "Column6";
            this.Column6.Visible = false;
            // 
            // Column7
            // 
            this.Column7.DataPropertyName = "manv";
            this.Column7.HeaderText = "manv";
            this.Column7.Name = "Column7";
            this.Column7.Visible = false;
            // 
            // frmSucKhoe
            // 
            this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.AutoScroll = true;
            this.ClientSize = new System.Drawing.Size(790, 571);
            this.Controls.Add(this.dataGridView1);
            this.Controls.Add(this.groupSK);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.panCongTac);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.Name = "frmSucKhoe";
            this.ShowInTaskbar = false;
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Hồ sơ nhân viên";
            this.Load += new System.EventHandler(this.frmSucKhoeSua_Load);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmSucKhoe_KeyDown);
            this.panCongTac.ResumeLayout(false);
            this.groupSK.ResumeLayout(false);
            this.groupSK.PerformLayout();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.panel2.ResumeLayout(false);
            this.panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion

		private void goicb()
		{		
			txtNhanDang.Text="";			
		}		
		private void butThem_Click(object sender, System.EventArgs e)
		{
			try
			{				
				tongso();				
			}
			catch{}
		}
		public void tongso()
		{
			try
			{
				ds=mDB.f_countNV();
				TSo=ds.Tables[0].Rows[0][0].ToString();
				txtTSo.Text="";
				txtTSo.Text=TSo.ToString();
			}
			catch{}
		}
		
		
		private bool IsNumeric (string strNum)
		{	
			int iNum;
			try
			{
				iNum = int.Parse(strNum);
				return true;
			}
			catch
			{
				return false;
			}
		}
		
		private void load_LBL()
		{			
			load_nhandang();
			load_gridsuckhoe();						
		}
		
		private void load_nhandang()
		{
            string ma_nv=lblMasoNVCT.Text;
            DataSet ds=mDB.get_data("select nhandang,manv from "+mDB.user+".hopdong where manv='"+ma_nv+"' order by lan desc");
            DataRow []r=ds.Tables[0].Select("manv='"+ma_nv+"'");
            txtNhanDang.Text=r[0]["nhandang"].ToString();
		}

		
		private void butHuy_Click(object sender, System.EventArgs e)
		{
			DataSet ds=new DataSet();
			string ma_nv=lblMasoNVCT.Text;
			DialogResult dr = MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy thông tin này?"),AccessData.Msg,MessageBoxButtons.YesNo);			
			if(dr == DialogResult.Yes) 			
			{	
				try
				{					
                    //mDB.f_Del10(ma_nv);					
                    //mDB.f_DelSKhd(ma_nv);
					load_gridsuckhoe();					
					ds=mDB.f_countNV();
					TSo=ds.Tables[0].Rows[0][0].ToString();
					txtTSo.Text="";
					txtTSo.Text=TSo.ToString();
					goicb();		
				}
				catch {}
			}	
		}

		private void txtNhanDang_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
				SendKeys.Send("{Tab}");	
		}

		private void txtNhanDang_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar==8)
				e.Handled=false;
		}

		private void txtTHSK_SK_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
				SendKeys.Send("{Tab}");	
		}

		private void txtL_SK_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
				SendKeys.Send("{Tab}");	
		}

		private void txtL_SK_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar==8)
				e.Handled=false;
		}

		private void txtTN_SK_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
				SendKeys.Send("{Tab}");	
		}	

		private void txtDN_SK_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
            if (e.KeyCode == Keys.Enter)
                checkthuongtat.Focus();
		}

		private void txtDN_SK_Validated(object sender, System.EventArgs e)
		{
            txtDN_SK.Text = txtDN_SK.Text.Trim();
            if (txtDN_SK.Text == "  /  /")
            {
                return;
            }
            if(txtDN_SK.Text!="" )
			{
				if(!mDB.kiemtrangayhople(txtDN_SK.Text.Trim()))
				{
					txtDN_SK.Focus();		
                    return ;
				}
				int dd=0,mm=0,yy=0;

				int ddns=0,mmns=0,yyns=0;				
				try
				{					
					ddns=int.Parse(txtDN_SK.Text.Substring(0,2));
					mmns=int.Parse(txtDN_SK.Text.Substring(3,2));
					yyns=int.Parse(txtDN_SK.Text.Substring(6,4));
				}catch{}
				dd=int.Parse(txtTN_SK.Text.Substring(0,2));
				mm=int.Parse(txtTN_SK.Text.Substring(3,2));
				yy=int.Parse(txtTN_SK.Text.Substring(6));				
				try
				{					
					if(yyns<yy)
					{
						MessageBox.Show(lan.Change_language_MessageText("Năm của từ ngày khám sức khỏe ") + txtTN_SK.Text + lan.Change_language_MessageText(" phải nhỏ hơn năm của đến ngày khám sức khỏe"),AccessData.Msg);
						txtDN_SK.Focus();
						return;
					}					
					if(yyns==yy)
					{
						if(mmns<mm)
						{
							MessageBox.Show(lan.Change_language_MessageText("Tháng của từ ngày khám sức khỏe ") + txtTN_SK.Text + lan.Change_language_MessageText(" phải nhỏ hơn tháng của đến ngày khám sức khỏe"),AccessData.Msg);
							txtDN_SK.Focus();
							return;
						}
						if(mmns==mm)
						{
							if(ddns<dd)
							{
								MessageBox.Show(lan.Change_language_MessageText("Ngày của từ ngày khám sức khỏe ") + txtTN_SK.Text + lan.Change_language_MessageText(" phải nhỏ hơn ngày của đến ngày khám sức khỏe"),AccessData.Msg);
								txtDN_SK.Focus();
								return;
							}
						}
					}
				}
				catch{}
				if(dd<=0 || dd >31)
				{
					MessageBox.Show(lan.Change_language_MessageText("Nhập đến ngày khám sức khỏe không hợp lệ"),AccessData.Msg);
					txtDN_SK.Focus();
					return;
				}
				if(mm<=0 || mm>12)
				{
					MessageBox.Show(lan.Change_language_MessageText("Nhập đến ngày khám sức khỏe không hợp lệ"),AccessData.Msg);
					txtDN_SK.Focus();
					return;
				}
				if(dd > DateTime.DaysInMonth(yy,mm))
				{
					MessageBox.Show(lan.Change_language_MessageText("Nhập đến ngày khám sức khoẻ không hợp lệ"),AccessData.Msg);
					txtDN_SK.Focus();
					return;
				}
			}
		}

		private void txtGC_SK_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
			{
				btn_luu.Focus();
			}
		}

		private void txtGC_SK_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar==8)
				e.Handled=false;
		}

		private bool kiemtrask()
		{
			if(txtTHSK_SK.Text=="") 
			{
				MessageBox.Show(lan.Change_language_MessageText("Nhập tình hình sức khỏe"),AccessData.Msg);				
				txtTHSK_SK.Focus();
				return false;
			}
			if(txtL_SK.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Nhập loại sức khoẻ"),AccessData.Msg);
				txtL_SK.Focus();
				return false;
			}
			if(txtTN_SK.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Nhập từ ngày"),AccessData.Msg);				
				txtTN_SK.Focus();
				return false;
			}
			if(txtDN_SK.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Nhập đến ngày"),AccessData.Msg);				
				txtDN_SK.Focus();
				return false;
			}
			return true;
		}
		private void dgrTTSucKhoe_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
				SendKeys.Send("{Tab}");	
		}

		private void menuItem1_Click(object sender, System.EventArgs e)
		{
			groupSK.Visible=true;
			txtTHSK_SK.Text="";
			txtL_SK.Text="";
			txtTN_SK.Text="";
			txtDN_SK.Text="";
			txtGC_SK.Text="";
			txtTHSK_SK.Focus();
		}

		private void load_gridsuckhoe()
		{
			string ma_nv;       
			try
			{
				ma_nv=lblMasoNVCT.Text;
				DataSet ads=mDB.f_suckhoe(ma_nv);
                dataGridView1.DataSource = ads.Tables[0];
                CurrencyManager cm = (CurrencyManager)BindingContext[dataGridView1.DataSource, dataGridView1.DataMember];
                DataView dv = (DataView)cm.List;
                dv.AllowNew = false;
                dv.AllowEdit = false;
			}
			catch{}
		}

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
            //string ma_nv,th_suckhoe,loai_,tu_ngay,den_ngay,ghi_chu;
            //ma_nv=lblMasoNVCT.Text;
            //try
            //{
            //    groupSK.Visible=false;
            //    int i=dgrTTSucKhoe.CurrentCell.RowNumber;
            //    if(i<0)  
            //        i=dgrTTSucKhoe.CurrentCell.RowNumber;
            //    if(i==dgrTTSucKhoe.CurrentCell.RowNumber) 
            //    {
            //        DialogResult dr = MessageBox.Show("Bạn có muốn hủy nhân viên này không","Hủy Nhân Viên",MessageBoxButtons.YesNo);								
            //        if(dr == DialogResult.Yes) 	
            //        {
            //            th_suckhoe=dgrTTSucKhoe[i,0].ToString();
            //            loai_=dgrTTSucKhoe[i,1].ToString();
            //            tu_ngay=dgrTTSucKhoe[i,2].ToString();
            //            den_ngay=dgrTTSucKhoe[i,3].ToString();
            //            ghi_chu=dgrTTSucKhoe[i,4].ToString();					
            //            mDB.t_DEL_dgrSK(ma_nv,th_suckhoe,loai_,tu_ngay,den_ngay,ghi_chu);
            //            i=dgrTTSucKhoe.CurrentRowIndex;	
            //            load_gridsuckhoe();
            //        }
            //    }  			    
            //}
            //catch{}
		}

		private void butKetThuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}		

		private void btnSua_Click(object sender, System.EventArgs e)
		{
			Ena_control(false);
			Ena_textbox(true);
			txtNhanDang.Enabled=false;
		}

		
		private void Ena_control(bool ena)
		{
			btn_them.Enabled=ena;
			btn_luu.Enabled=!ena;
			btn_boqua.Enabled=!ena;
			btn_huy.Enabled=!ena;
			btn_xoa.Enabled=!ena;
			btn_thoat.Enabled=ena;
            btn_edit.Enabled =! ena;
		}
		private void Ena_textbox(bool ena)
		{
			txtNhanDang.Enabled=ena;
			txtTHSK_SK.Enabled=ena;
			txtL_SK.Enabled=ena;
			txtTN_SK.Enabled=ena;
			txtDN_SK.Enabled=ena;
			txtGC_SK.Enabled=ena;
            checkthuongtat.Enabled = ena;
            cmbloai.Enabled = ena;
		}
		private void clear_Text()
		{
			txtTHSK_SK.Clear();
			txtL_SK.Clear();
			txtTN_SK.Clear();
			txtDN_SK.Clear();
			txtGC_SK.Clear();
		}	
	
		private void CapnhatData()
		{
            string ma_nv="", nd="",th_suckhoe = "", loai_ = "", tu_ngay = "", den_ngay = "", ghi_chu = "",loai_tt="";
            decimal m_id = 0;
            bool thuongtat = false;
            ma_nv = lblMasoNVCT.Text;
            nd = txtNhanDang.Text;
            mDB.upd_SucKhoe(ma_nv, nd);
            
			if(!kiemtrask()) return;
			ma_nv=lblMasoNVCT.Text;
			th_suckhoe=txtTHSK_SK.Text;
			loai_=txtL_SK.Text;
			tu_ngay=txtTN_SK.Text;
			den_ngay=txtDN_SK.Text;
			ghi_chu=txtGC_SK.Text;
            loai_tt = cmbloai.Text.Trim();
            if (checkthuongtat.Checked == true)
            {
                thuongtat = true;
            }
            else
            {
                thuongtat = false;
            }
          
            if (flag == 0)
            {
                m_id = decimal.Parse(get_maxid());

            }
            else
            {
              
                if (txtID.Text != "")
                    m_id = decimal.Parse(txtID.Text.ToString());
            }
           
            mDB.upd_SucKhoe(m_id, ma_nv, th_suckhoe, loai_, tu_ngay, den_ngay,thuongtat,loai_tt, ghi_chu,ten_nd);
			load_gridsuckhoe();				
				
		}

		private void frmSucKhoeSua_Load(object sender, System.EventArgs e)
		{
            txtID.Hide();
            load_LBL();
            Ena_control(true);
			Ena_textbox(false);
		}

		private void btnKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		

        private void cmdLuu_SK_Click(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataRowView arv = (DataRowView)(dataGridView1.CurrentRow.DataBoundItem);
                txtID.Text = arv["id"].ToString();
                txtTHSK_SK.Text = arv["benhly"].ToString();
                txtL_SK.Text = arv["loai"].ToString();
                txtTN_SK.Text = arv["tg_dau"].ToString();
                txtDN_SK.Text = arv["tg_cuoi"].ToString();
                txtGC_SK.Text = arv["ghichu"].ToString();
            }
            catch
            {
            }
            Ena_control(false);
            btn_edit.Enabled = admin;
            btn_huy.Enabled = admin;
            btn_xoa.Enabled = admin;
        }

        private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
        {
            dataGridView1_CellClick(null, null);
        }

        private void checkthuongtat_CheckedChanged(object sender, EventArgs e)
        {
            if (checkthuongtat.Checked)
                cmbloai.Enabled = true;
            else            
                cmbloai.Enabled = false;
        }

        private void checkthuongtat_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}{F4}");
        }

        private void cmbloai_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }
        //get maxid
        private string get_maxid()
        {
            decimal m_id = 0;
            sql = "select max(id)+1 as max_id from " + m_user + ".suckhoe ";
            DataSet dst = new DataSet();
            try
            {
                dst = mDB.get_data(sql);
                if (dst.Tables[0].Rows[0]["max_id"].ToString() != "")
                {
                    m_id = decimal.Parse(dst.Tables[0].Rows[0]["max_id"].ToString());
                }
                else
                    m_id = 1;
            }
            catch
            {
                m_id = 1;
            }
            return m_id.ToString();
        }
        //
        private void btn_them_Click(object sender, EventArgs e)
        {
            //int m_id = 0, iid = 0;
            //sql = "select max(id) as Iid from " + mDB.user + ".suckhoe ";
            //DataSet dst = new DataSet();
            //dst = mDB.get_data(sql);
            //foreach (DataRow r in dst.Tables[0].Rows)
            //{
            //    try
            //    {
            //        m_id = int.Parse(r["iid"].ToString());
            //    }
            //    catch
            //    {
            //        m_id = 0;
            //    }
            //}
            //iid = m_id + 1;
            //txtID.Text = iid.ToString();


            Ena_control(false);
            Ena_textbox(true);
            clear_Text();
            txtTHSK_SK.Focus();
            flag = 0;
        }

        private void btn_edit_Click(object sender, EventArgs e)
        {
            Ena_control(false);
            Ena_textbox(true);
            btn_them.Enabled = false;
            txtTHSK_SK.Focus();
            flag = 1;
        }

        private void btn_luu_Click(object sender, EventArgs e)
        {
            try
            {
                CapnhatData();
                Ena_control(true);
                Ena_textbox(false);
                btn_them.Focus();
                flag = 0;
            }
            catch { }
        }

        private void btn_boqua_Click(object sender, EventArgs e)
        {
            Ena_control(true);
            Ena_textbox(false);
            btn_thoat.Focus();
            flag = 0;
        }

        private void btn_huy_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            string ma_nv = lblMasoNVCT.Text;
            DialogResult dr = MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy thông tin này?"), AccessData.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    mDB.Execute_data("DELETE  FROM " + mDB.user + ".suckhoe WHERE manv='" + ma_nv + "'");
                    mDB.Execute_data("UPDATE " + mDB.user + ".hopdong SET nhandang='' WHERE manv='" + ma_nv + "'");
                    load_gridsuckhoe();
                    ds = mDB.f_countNV();
                    TSo = ds.Tables[0].Rows[0][0].ToString();
                    txtTSo.Text = "";
                    txtTSo.Text = TSo.ToString();
                    goicb();
                }
                catch { }
                Ena_control(true);
                flag = 0;
            }	
        }

        private void btn_xoa_Click(object sender, EventArgs e)
        {   
            try
            {

                DialogResult dr = MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy thông tin này?"), AccessData.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    sql = "delete from " + mDB.user + ".suckhoe  where id=" + txtID.Text;
                    mDB.Execute_data(sql);
                    load_gridsuckhoe();
                    Ena_control(true);
                }
            }
            catch { }
            flag = 0;
        }

        private void btn_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_luu_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btn_them.Focus();
        }

        private void btn_them_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                txtTHSK_SK.Focus();
        }

        private void frmSucKhoe_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Alt && e.KeyCode == Keys.T)
            {
                btn_them_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.S)
            {
                btn_edit_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.H)
            {
                btn_huy_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.L)
            {
                btn_luu_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.B)
            {
                btn_boqua_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.X)
            {
                btn_xoa_Click(null, null);
            }
            if (e.Alt && e.KeyCode == Keys.K)
            {
                btn_thoat_Click(null, null);
            }
        }

        private void txtTN_SK_Validated(object sender, EventArgs e)
        {
            if (txtTN_SK.Text.Trim() != "")
            {
                if (!mDB.kiemtrangayhople(txtTN_SK.Text.Trim()))
                {
                    MessageBox.Show(lan.Change_language_MessageText("Nhập ngày không hợp lệ"),AccessData.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTN_SK.Focus();
                    return;
                }
            }
        }
	}
}
